﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class CharacterManager 
{
	private Dictionary<int, Character> dicCharater = new Dictionary<int, Character>();

    public Character AddCharacter(int idx, CharacterData charData)
	{
		if (dicCharater.ContainsKey (idx) == true) 
		{
			Debug.Log( "already contain character, key index : " + idx.ToString() );
			return null;
		}

        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Character/Prefabs/" + charData.fileName));
        NormalTank normalTank = obj.GetComponent<NormalTank>();
        dicCharater.Add(idx, normalTank);

        return normalTank;
	}


	public Character GetCharacter( int idx )
	{
		Character character = null;

		if (dicCharater.TryGetValue (idx, out character) == true) 
		{
			return character;
		}

		Debug.Log ("not find character idx : " + idx.ToString ());

		return null;
	}
}
